home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / genji / src / command.c next >
Text File  |  1995-02-09  |  4KB  |  255 lines

  1. #include "genji.h"
  2.  
  3. void    setAsciiMode()
  4. {
  5.     if( mode != 'A' )
  6.     {
  7.         mode = 'A';
  8.         bufp += addstrings( scsank, bufp );
  9.     }
  10.     return;
  11. }
  12.  
  13. void    setKanjiMode()
  14. {
  15.     if( mode != 'K' )
  16.     {
  17.         mode = 'K';
  18.         bufp += addstrings( scsjis, bufp );
  19.     }
  20.     return;
  21. }
  22.  
  23. int        flushBuffer()
  24. {
  25.     int        e;
  26.  
  27.     while( e = printStrings( (bufp-outbuf), outbuf ) )
  28.     {
  29.         if( printReady( e ) )
  30.             return ERR;
  31.     }
  32.     bufp = outbuf;
  33.  
  34.     return NOERR;
  35. }
  36.  
  37. void    printPage( int page )
  38. {
  39.     int    s[3],i,j;
  40.  
  41.     j = 0;
  42.     bufp += addstrings( pagep, bufp );
  43.     setAsciiMode();
  44.  
  45.     *bufp++ = '-';
  46.     *bufp++ = ' ';
  47.     num2str( s, page, 3 );
  48.     for( i=0; i<3; i++ )
  49.     {
  50.         if( s[i] )
  51.             j = 1;
  52.         if( j )
  53.             *bufp++ = (char)(s[i]) + '0';
  54.     }
  55.     *bufp++ = ' ';
  56.     *bufp++ = '-';
  57.     *bufp++ = 0x0a;
  58.     *bufp++ = 0;
  59.  
  60.     return;
  61. }
  62.  
  63. void    setKanjiSize( int c )
  64. {
  65.     int        s1[4],s2[4];
  66.     const static int    kbai[3] = { 50, 100, 200 };
  67.  
  68.     num2str( s1, kbai[(c&0x0f)   ], 3 );
  69.     num2str( s2, kbai[(c&0xf0)>>4], 3 );
  70.     ksize[2] = s1[0] + 0x20;
  71.     ksize[3] = s1[1] + 0x20;
  72.     ksize[4] = s1[2] + 0x60;
  73.     ksize[5] = s2[0] + 0x20;
  74.     ksize[6] = s2[1] + 0x20;
  75.     ksize[7] = s2[2] + 0x70;
  76.     ksize[8] = 0;
  77.     bufp += addstrings( ksize, bufp );
  78.     pitchmask = kbai[c&0xf0>>4] / 50;
  79.     info[np][1] = c;
  80.     return;
  81. }
  82.  
  83. void    setLeftmargin( int lm )
  84. {
  85.     int        s[2];
  86.  
  87.     if( lm<0 || lm>80 )
  88.         lm = 0;
  89.     num2str( s, lm, 2 );
  90.     lmrg[5] = s[0] + 0x30;
  91.     lmrg[6] = s[1] + 0x30;
  92.     bufp += addstrings( lmrg, bufp );
  93.     return;
  94. }
  95.  
  96. void    lineInit()
  97. {
  98.     usrjis = 0x2a21;
  99.     x_pos = leftmargin*27;
  100.     lineflg = OFF;
  101.     control = OFF;
  102.  
  103.     return;
  104. }
  105.  
  106. void    lineTerm()
  107. {
  108.     y_pos += cr_p;
  109.     net_sp = leftmargin*27;
  110.     net_length = 0;
  111.  
  112.     return;
  113. }
  114.  
  115.  
  116. void    setFontType( int type )
  117. {
  118.     if( type<0 || type>4 )
  119.         type = 0;
  120.     info[np][0] = type;
  121.     switch( type )
  122.     {
  123.         case 0:
  124.             bufp += addstrings( mintyo, bufp );
  125.             break;
  126.         case 1:
  127.             bufp += addstrings( gothic, bufp );
  128.             break;
  129.     }
  130.     return;
  131. }
  132.  
  133. void    setPrintDirection( int dir )
  134. {
  135.     if( dir == 1 )
  136.         bufp += addstrings( vws, bufp );
  137.     else
  138.         bufp += addstrings( hws, bufp );
  139.     return;
  140. }
  141.  
  142. void    setNetStart()
  143. {
  144.     net_flg = ON;
  145.     net_sp = x_pos;
  146.     return;
  147. }
  148.  
  149. void    setNetEnd()
  150. {
  151.     net_length = x_pos - net_sp;
  152.     net_flg = OFF;
  153.     return;
  154. }
  155.  
  156. void    printNet()
  157. {
  158.     int        ss[4],sl[4],i,j;
  159.  
  160.     num2str( ss, net_sp, 4 );
  161.     num2str( sl, net_length, 4 );
  162.     for( i=0; i<4; i++ )
  163.     {
  164.         netst[2+i] = (char)(ss[i]) + 0x30;
  165.         netst[9+i] = (char)(sl[i]) + 0x30;
  166.     }
  167.     bufp += addstrings( netst, bufp );
  168.  
  169.     if( net_length > 0 )
  170.         for( j=0; j<net_length; j++ )
  171.             for( i=0; i<6; i++ )
  172.                 *bufp++ = netdata[net_sort][(j&7)*6+i];
  173.  
  174.     return;
  175. }
  176.  
  177. void    setHorizonPos( int x )
  178. {
  179.     int        s[4];
  180.  
  181.     if( x<0 )
  182.         x = 0;
  183.     num2str( s, x, 4 );
  184.     mov_h[2] = s[0] + 0x30;
  185.     mov_h[3] = s[1] + 0x30;
  186.     mov_h[4] = s[2] + 0x30;
  187.     mov_h[5] = s[3] + 0x30;
  188.     bufp += addstrings( mov_h, bufp );
  189.     return;
  190. }
  191.  
  192. void    setBaseLine( int p )
  193. {
  194.     if( p<0 || p>2 )
  195.         p = 0;
  196.     sbase[2] = p + 0x30;
  197.     bufp += addstrings( sbase, bufp );
  198.     return;
  199. }
  200.  
  201. void    setLineConnect( int p )
  202. {
  203.     if( p == ON )
  204.         bufp += addstrings( linon, bufp );
  205.     else
  206.         bufp += addstrings( linoff, bufp );
  207.     return;
  208. }
  209.  
  210. void    setUnderline( int p )
  211. {
  212.     if( p == ON )
  213.         bufp += addstrings( kuon, bufp );
  214.     else
  215.         bufp += addstrings( kuoff, bufp );
  216.     return;
  217. }
  218.  
  219. void    setKanjiPitch( int p )
  220. {
  221.     int        s[4];
  222.  
  223.     if( p<48 || p>120 )
  224.         p = 54;
  225.     num2str( s, p, 3 );
  226.     knjp[2] = s[0] + 0x20;
  227.     knjp[3] = s[1] + 0x20;
  228.     knjp[4] = s[2] + 0x70;
  229.     bufp += addstrings( knjp, bufp );
  230.     return;
  231. }
  232.  
  233. void    setReturnPitch( int p )
  234. {
  235.     int        s[4];
  236.  
  237.     if( p<1 || p>120 )
  238.         p = 60;
  239.     num2str( s, p, 3 );
  240.     retp[2] = s[0] + 0x20;
  241.     retp[3] = s[1] + 0x20;
  242.     retp[4] = s[2] + 0x70;
  243.     bufp += addstrings( retp, bufp );
  244.     return;
  245. }
  246.  
  247. void    setColorReverse()
  248. {
  249.     if( colrev_flg == ON )
  250.         colrev_flg = OFF;
  251.     else
  252.         colrev_flg = ON;
  253.  
  254. }
  255.